package unilearn.facade;

import java.sql.SQLException;
import java.util.Vector;
import javax.naming.*;

import unilearn.da.DAAssignment;
import unilearn.domain.Assignment;
import unilearn.domain.Submission;

/**
 * @author David Oliver, 4084551
 * @version 0.1 Apr 30, 2008, initial creation, dro
 * @version 0.2 Apr 30, 2008, added basic insert/update/delete methods, dro
 */
public class AssignmentFacade
{
	public static long addAssignment(Assignment assign) throws SQLException, NamingException
	{
		return DAAssignment.insertAssignment(assign);
	}

	public static Assignment getAssignmentByID(long assignmentID) throws SQLException, NamingException
	{
		return DAAssignment.getAssignmentByID(assignmentID);
	}

	public static Vector<Assignment> getAssignmentBySubject(long subjectID)
		throws SQLException, NamingException
	{
		return DAAssignment.getAssignmentBySubject(subjectID);
	}

	public static Assignment getAssignmentBySubmission(Submission sub) throws SQLException, NamingException
	{
		long assignmentID = sub.getAssignmentID();
		return getAssignmentByID(assignmentID);
	}
	
	public static void updateAssignment(long assignmentID, Assignment assign)
		throws SQLException, NamingException
	{
		DAAssignment.updateAssignment(assignmentID, assign);
	}

	public static void deleteAssignment(long assignmentID) throws SQLException, NamingException
	{
		DAAssignment.deleteAssignment(assignmentID);
	}
}
